#include "../Helix/View/OpenGL/OpenGLSupport.h"

#include "../Helix/Helix.h"
#include "../Helix/Input.h"
#include "../Helix/Timer.h"
#include "../Helix/Math/Constants.h"
#include "MeshExample.h"					// Header File For Derived Application Class
#include <math.h>

using namespace helix;

void MeshExample::renderScene()
{
	glMatrixMode(GL_MODELVIEW);
	glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT);
	
	
	//this is where everything in the main rendering loop should go
	glLoadIdentity();			//Reset the modelview matrix to the identity matrix

	//Save the current matrix transformation
	glPushMatrix();
	//Translate the cube into the screen and to the left
	glTranslatef(-2.0,0.0,-7.5);

	//Rotate the cube so that it looks interesting
	glRotatef(rotX,1.0,0.0,0.0);
	glRotatef(rotY,0.0,1.0,0.0);
	glRotatef(rotX * 0.5f,0.0,0.0,1.0);

	openGLHelper->drawMesh(cube);
	

	//Get the saved matrix transformation
	glPopMatrix();
	//Translate the cube into the screen and to the right
	glTranslatef(2.0,0.0,-7.5);

	//Rotate the cube so that it looks interesting
	glRotatef(rotX * 0.5f,0.0,0.0,1.0);
	glRotatef(rotY,0.0,1.0,0.0);
	glRotatef(rotX,1.0,0.0,0.0);

	openGLHelper->drawMesh(cube2);

	glFlush();
}

void MeshExample::update(double dSeconds)
{
	rotX+= (float)dSeconds * RADTODEG / 1.0f;
	rotY+= (float)dSeconds * RADTODEG / 0.57f;
}
